﻿using PMS.Data.Entities.Customers;
using PMS.Data.Entities.Stores;
using PMS.Data.Entities.SystemModules;
using System.Collections.Generic;

namespace PMS.Services.EntityServices.SystemModules
{
    /// <summary>
    /// Represent to Service For SystemModuleEntity
    /// </summary>
    public partial interface ISystemModuleService
    {
        #region SystemModule
        /// <summary>
        /// Gets all SystemModules within Store
        /// </summary>
        /// <param name="storeId">Store identifier</param>
        /// <returns>system module list</returns>
        IList<SystemModule> GetAllSystemModulesInStore(int storeId);

        /// <summary>
        /// 获取当前用户所有有权限查看的系统菜单模块
        /// 根据AdminAreaSettings.DisplayAllSystemMenus设置提供两种模式的后台系统菜单显示
        /// True: 则全量显示后台系统菜单，当用户打开页面时根据用户权限展示内容或显示无操作权限等信息
        /// False:按用户角色分配的权限加载有查看权限的系统模块菜单展示
        /// </summary>
        /// <param name="customerId"></param>
        /// <returns></returns>
        IList<SystemModule> GetSysteModulesByCustomer(int storeId, int customerId);

        /// <summary>
        /// Get SystemModule List By Role
        /// </summary>
        /// <param name="store"></param>
        /// <param name="role"></param>
        /// <param name="showHidden">whether show SystemModules when "ViewPermission" off to CustomerRole</param>
        /// <returns></returns>
        IList<SystemModule> GetSysteModulesByRole(CustomerRole role, Store store, bool showHidden = false);
        /// <summary>
        /// Get SystemModule by Id
        /// </summary>
        /// <param name="moduleid"></param>
        /// <returns></returns>
        SystemModule GetSystemModuleById(int moduleId);

        /// <summary>
        /// Insert a SystemModule entity
        /// </summary>
        /// <param name="module">SystemModule</param>
        SystemModule InsertSystemModule(SystemModule moduleEntity);

        /// <summary>
        /// Delete a SystemModule and its RoleMapping, StoreMapping
        /// </summary>
        /// <param name="moduleEntity"></param>
        void DeleteSystemModule(SystemModule moduleEntity);

        /// <summary>
        /// Update SystemModule Entity
        /// </summary>
        /// <param name="moduleEntity"></param>
        void UpdateSystemModule(SystemModule moduleEntity);
        #endregion

        #region SystemModule-CustomerRole Mappings
        /// <summary>
        /// Get All SystemModule-CustomerRole Mappings of all CustomerRoles By SystemModuleId
        /// </summary>
        /// <param name="moduleId"></param>
        /// <returns></returns>
        IList<SystemModuleCustomerRoleMapping> GetSystemModuleCustomerRoleMappingsBySystemModuleId(int moduleId);
        /// <summary>
        /// Get SystemModuleCustomerRoleMapping List By CustomerRole
        /// </summary>
        /// <param name="role"></param>
        /// <returns></returns>
        IList<SystemModuleCustomerRoleMapping> GetSystemModuleCustomerRoleMappingsByCustomerRole(CustomerRole role);
        /// <summary>
        /// Add a system module-customer role mapping
        /// </summary>
        /// <param name="moduleroleMapping">SystemModule-customer role mapping</param>
        void AddSystemModuleCustomerRoleMapping(SystemModuleCustomerRoleMapping moduleroleMapping);
        /// <summary>
        /// Update a system module-customer role mapping
        /// </summary>
        /// <param name="moduleroleMapping">SystemModule-customer role mapping</param>
        void UpdatedSystemModuleCustomerRoleMapping(SystemModuleCustomerRoleMapping moduleroleMapping);
        /// <summary>
        /// 更新同一用户角色下的所有系统模块权限
        /// </summary>
        /// <param name="role"></param>
        /// <param name="mappings"></param>
        void UpdateSystemModuleCustomerRoleMappingsWithSameCustomerRole(CustomerRole role, IList<SystemModuleCustomerRoleMapping> mappings);
        /// <summary>
        /// Remove a system module-customer role mapping
        /// </summary>
        /// <param name="module">SystemModule</param>
        /// <param name="role">Customer role</param>
        void RemoveSystemModuleCustomerRoleMapping(SystemModule module, CustomerRole role);

        /// <summary>
        /// Remove system module-customer role mappings by systemmoduleId OR roleId
        /// </summary>
        /// <param name="moduleId"></param>
        /// <param name="roleId"></param>
        void RemoveSystemModuleCustomerRoleMapping(int? moduleId = null, int? roleId = null);
        #endregion

        #region ModuleButtons
        /// <summary>
        /// 通过Id数组获取指定系统模块所分配的按钮
        /// </summary>
        /// <param name="moduleId">systemmodule id for cachekey</param>
        /// <param name="btnIds"></param>
        /// <returns></returns>
        IList<ModuleButton> GetModuleAssignedButtonsByIds(int moduleId, int[] btnIds);

        /// <summary>
        /// 获取所有系统模块按钮
        /// </summary>
        /// <returns></returns>
        IList<ModuleButton> GetAllModuleButtons();
        #endregion
    }
}
